package com.hzit.portal.listener;

import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.system.api.domain.Content;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Component
@RabbitListener(queues = "hzit-content")
@Slf4j
public class HzitAddContentListener {

	@Autowired
	private RedisService redisService;

	/**
	 * 将添加的一条记录添加到redis中
	 * @param content
	 * @return
	 */
	@RabbitHandler
	public void getMessage(Content content){
		redisService.setCacheMapValue(CacheConstants.CONTENT_LIST,content.getId() + "",content);
		log.info("同步一条记录{}到redis.",content);
	}


}
